package com.example.kafka.controller;

import com.example.kafka.model.Order;
import com.example.kafka.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单控制器
 */
@RestController
@RequestMapping("/api/orders")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 创建订单
     */
    @PostMapping
    public Order createOrder(@RequestParam String userId, @RequestParam double amount) {
        return orderService.createOrder(userId, amount);
    }

    /**
     * 查询订单
     */
    @GetMapping("/{orderId}")
    public Order getOrder(@PathVariable String orderId) {
        return orderService.getOrder(orderId);
    }
} 